#ifndef GLOBAL_H
#define GLOBAL_H
//for mapping
#include <sys/types.h>
#include <sys/ipc.h>
#include <sys/shm.h>
#include <errno.h>
#include <unistd.h>
#include <string.h>
#include <stdlib.h>
#include <iostream>
#include <queue>
#include <vector>

#include <ucontext.h>


#include <signal.h>
#include <fcntl.h>
#include <sys/mman.h>
#include <sys/wait.h>
#include <stdio.h>


#define BUFFERSIZE 256;

// structures for shared memory
#define MAXCHAR 256	

#ifndef INPUTBUF
#define INPUTBUF
typedef struct {
	int ok_flag;
	char indata[MAXCHAR];
	int length;
} inputbuf;

#endif

//Global info
#define Num_Proc 9//A,B,C,CCI,clock,timeout,KB,CRT,null
#define Num_PriorityLevels 4

//blocked-on-receive,blocked-on-resource
#define Num_BlockedPriorityLevels 4

//blocked on receive queue has 4 priority levels
//define blocked type and the according number here
#define Num_MsgEnv 50
#define Max_Env_Data 256
#define TraceBufferSize 16
#define StackSize 16384

//define return codes
#define success 0
#define error1 1 //enqueue failed
#define error2 2 //

//define PIDs
//to help make the code easier to understand
#define ProcessA 0
#define ProcessB 1
#define ProcessC 2
#define CCI 3
#define KB 4
#define CRT 5
#define Clock 6
#define Timer 7
#define NullProcess 8

//defined PCB status code here
//#define I_Process 0
//#define Executing 1
//#define Ready 2
//#define Blocked_On_Receive 3
//#define Blocked_On_Resource 4
#define Executing 0
#define Ready 1
#define Blocked_On_Receive 2
#define Blocked_On_Resource 3
//Priority
#define I_Process 4

//defined msg types here
#define wakeup_code 0 //request_delay
#define display_ack 1
#define console_input 2
#define request_input 3
#define request_output 4
#define status_report 5 //request_process_status
#define count_report 6 //for process A message to B
//define wakeup10 7    //for process C 

//for  atomic on and off
#define ON 1
#define OFF 0

//for add atrace
#define Type_Send 0
#define Type_Receive 1

#endif
